package com.googlecode.likesql.expression;

import com.googlecode.likesql.utils.ArrayUtils;

/**
 * ArrayExp represents the an object array container.
 * @author Johny Huang
 * @since 0.1
 * @see {@link com.googlecode.likesql.converter.ArrayExpConverter ArrayExpConverter}
 *
 */
public class ArrayExp {

	private Object[] array;
	
	private ArrayExp(Object[] objs){
		this.array=objs;
	}
	
	/**
	 * Get a new instance which contains values array.
	 * @param values
	 * @return
	 */
	public static ArrayExp array(Object[] values){
		return new ArrayExp(values);
	}
	
	/**
	 * Get a new instance which contains values array.
	 * @param values
	 * @return
	 */
	public static ArrayExp array(double[] values){
		return new ArrayExp(ArrayUtils.toObjectArray(values));
	}
	
	/**
	 * Get a new instance which contains values array.
	 * @param values
	 * @return
	 */
	public static ArrayExp array(float[] values){
		return new ArrayExp(ArrayUtils.toObjectArray(values));
	}
	
	/**
	 * Get a new instance which contains values array.
	 * @param values
	 * @return
	 */
	public static ArrayExp array(int[] values){
		return new ArrayExp(ArrayUtils.toObjectArray(values));
	}
	
	/**
	 * Get a new instance which contains values array.
	 * @param values
	 * @return
	 */
	public static ArrayExp array(long[] values){
		return new ArrayExp(ArrayUtils.toObjectArray(values));
	}
	
	/**
	 * Get a new instance which contains values array.
	 * @param values
	 * @return
	 */
	public static ArrayExp array(char[] values){
		return new ArrayExp(ArrayUtils.toObjectArray(values));
	}
	
	/**
	 * Get the internal object array.
	 * @param values
	 * @return
	 */
	public Object[] getArray(){
		return array;
	}
}
